<template>
    <div>
        <Form :label-width="100" inline>
            <FormItem label="行政区划" prop="areacode">
                <area-linkage :areaCode.sync="queryParam.ssca0043" :countyDisable=false :streetDisable=false
                              :communityDisable=false></area-linkage>
            </FormItem>
            <Form-item label="户主姓名">
                <Input v-model="queryParam.azcp0003" placeholder="请输入户主姓名"
                       style="width: 200px"></Input>
            </Form-item>
            <Form-item label="证件号码">
                <Input v-model="queryParam.azcp0001" placeholder="请输入证件号码"
                       style="width: 200px"></Input>
            </Form-item>
        </Form>
        <Row class="button_row">
                <span style="float: left;">
                  <Button type="primary" @click="handleAdd()">录入</Button>
                </span>
            <span style="float: right;">
                 <Button type="primary" @click="searchQuery">查询</Button>
                 <Button type="primary" class="button_item_left" @click="searchReset">重置</Button>
                </span>
        </Row>
        <applicationIndex ref="applicationIndex"></applicationIndex>
        <applicationIndexForView ref="applicationIndexForView"></applicationIndexForView>
        <div class="table_div">
            <vxe-table border
                       resizable
                       row-id="id"
                       :row-key="true"
                       show-overflow="tooltip"
                       align="center"
                       header-align="center"
                       ref="xTree"
                       :loading="Loading"
                       :radio-config="{highlight: true}"
                       :data="tableData">
                <vxe-table-column field="azcp0003" title="户主姓名" align="center" width="120" fixed="left"/>
                <vxe-table-column field="azcp0001" title="证件号码" align="center" width="180" fixed="left"/>
                <vxe-table-column field="azaa0002" title="户口所在地" align="center" width="240" fixed="left"/>
                <vxe-table-column field="azdf0500" title="家庭详细地址" align="center" width="240"/>
                <vxe-table-column field="azdf0011" title="联系电话" align="center" width="120"/>
                <vxe-table-column field="azcp0014" title="测评操作人" align="center" width="140"/>
                <vxe-table-column field="azcp0013" title="测评日期" align="center" width="110" :formatter="renderTime"/>
                <vxe-table-column field="azcp0012" title="测评结果" align="center" width="350"/>
                <vxe-table-column field="" title="操作" min-width="200" fixed="right">
                    <template v-slot="{ row }">
                        <Button type="warning" size="small" style="margin-right: 5px" @click="handleEdit(row)">编辑
                        </Button>
                        <Button type="success" size="small" style="margin-right: 5px" @click="handleDetail(row)">详情
                        </Button>
                        <Button type="error" size="small" style="margin-right: 5px" @click="handleDelete(row)">删除
                        </Button>
                    </template>
                </vxe-table-column>
            </vxe-table>

            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange" :current="pageNo"></Page>
        </div>
    </div>
</template>

<script>
    import {postAction} from '@/api/request'
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import applicationIndex from './index'
    import applicationIndexForView from './view/index'

    export default {
        mixins: [CommonMixin],
        components: {
            applicationIndex,
            applicationIndexForView
        },
        data() {
            return {
                tableData: [],
                Loading: false,
                url: {
                    list: "/api/ac/subsistence/ss02050Service/getPageList",
                    delete: "/api/ac/subsistence/ss02050Service/deleteData",
                },
                queryParam: {},
                dataCount: 0,
                dataCountNoBankInfo: 0,
                pageSize: 10,
                modal: false,
                selectedData: '',
            }
        },
        methods: {
            handleAdd() {
                this.$refs.applicationIndex.add();
                this.$refs.applicationIndex.key = this.uuid();
            },
            handleDetail(row) {
                let that = this;
                this.$refs.applicationIndexForView.view(row);
                this.$refs.applicationIndexForView.key = this.uuid();
            },
            handleEdit(row) {
                let that = this;
                this.$refs.applicationIndex.edit(row);
                this.$refs.applicationIndex.key = this.uuid();
            },
            handleDelete(row) {
                let that = this;
                this.$Modal.confirm({
                    title: '确定删除吗？',
                    onOk: () => {
                        postAction(that.url.delete, row).then((res) => {
                            if (res.data.errcode == 0) {
                                //重新计算分页问题
                                that.reCalculatePage(1);
                                that.$Message.success("删除成功！");
                            } else {
                                that.$Message.error(res.data.errmsg);
                            }
                        });
                    }
                })
            },
        },
        created() {
            this.loadData();
        },
    }
</script>
<style scoped>
    /deep/ .ivu-form-item-error-tip {
        display: none;
    }

    .itemStyle {
        width: 180px
    }

    .head-img1 {
        height: 200px;
        width: 250px;
        margin-top: 15px;
    }

    .head-img {
        height: 200px;
        width: 250px;
    }

    .imgBackColor {
        background-color: WhiteSmoke;
        height: 250px;
    }

    .positiveTDiv {
        height: 240px;
        width: 75px;
        line-height: 240px;
        background-color: #7CCD7C;
        margin-bottom: 10px;
        color: white;
        font-size: 14px;
        font-weight: 700;
    }
</style>
